#ifndef KEY_GENERATOR_H
#define KEY_GENERATOR_H
#include <QtCore>
#include <QtSql>

#include <QString>
#include <cryptopp/rsa.h>
#include <cryptopp/osrng.h>
#include <cryptopp/files.h>
#include <cryptopp/hex.h>
#include <cryptopp/pssr.h>
#include <cryptopp/cryptlib.h>

#include <string>

using namespace std;
using namespace CryptoPP;


class key_generator
{
public:
//Variables
//    QString ObjName;
//    QString BG_key;
    QDir obj_Dir;


//Funciones
    key_generator();
    key_generator(QString Dir);
    key_generator(QString Dir, bool no_key);

    ~key_generator();

    void create_key(QString key_name);
    QString encryptMsg(QString Data,QString keyName);
    bool decryptMsg(QString Data, QString &decryptedMsg);
    QString signMsg(QString msg);
    bool verifyMsg(QString msg,QString keyToUse, QString &verifiedMsg);

    bool M2(QString &m2,QString &m4);
    bool Key2Hex(QString keyname,QString &keyHex);
    bool Search_in_KGBB(QString Hash,QString column);

    void SubVotingKeyList();

private:
//Variables

    AutoSeededRandomPool rng;


//Funciones
    void Save(QString &filename, const BufferedTransformation& bt);
    void SavePrivateKey(QString &filename, const PrivateKey& key);
    void SavePublicKey(QString &filename, const PublicKey& key);

    void Load(QString filename, BufferedTransformation& bt);
    void LoadPrivateKey(QString filename, PrivateKey& key);
    void LoadPublicKey(QString filename, PublicKey& key);
    QString Hash(QString keyname1, QString keyname2);

    QString shift_String(QString &msg);
    QString shift_String(QString &msg,int max);

    bool Save_in_VKL();

    bool Hex2Key(QString keydata,QString keyname);

    bool Save_Hashes();



};

#endif // KEY_GENERATOR_H
